package com.hr.builder;

import org.springframework.stereotype.Component;

import com.espirit.eap.manager.ModelBuilderSupport;
import com.espirit.eap.manager.RelatedModel;
import com.espirit.eap.manager.TabbedModel;
import com.hr.LeaveAppItem;
import com.hr.SalaryTicket;
import com.hr.SalaryTicketLateItem;
import com.hr.SalaryTicketLeaveEarlyItem;

@Component
public class SalaryTicketBuilder extends ModelBuilderSupport {
	static final String EMPLOYEE = "employee";
	static final String LEAVEAPPHOURS = "leaveAppHours";
	static final String DELIVERYTIMES ="deliveryTimes";
	static final String FAULTAMOUNT = "rewardFaultAmount";
	static final String OTHOURS = "otHours";
	static final String ABSENTDAYS = "absentDays";
	
	static final String LATEMINUTES = "lateMinutes";
	static final String LATETIMES = "lateTimes";
	static final String SCHEDUALDAYS = "schedualDays";
	static final String DUTYDAYS = "dutyDays";
	
	static final String DUTYFORGETTIMES = "dutyForgetTimes";
	static final String DUTYSUBSTITUTETIMES = "dutySubstituteTimes";
	
	static final String SCHEDUALHOURS = "schedualHours";
	static final String DUTYHOURS = "dutyHours";
	
	static final String DAYSALARY = "daySalary";
	static final String HOURSALARY = "hourSalary";
	
//	static final String ACCTTERM = "acctTerm";
//	static final String DEPARTMENT = "department";
	
//	FunctionButton reCalcTicket = null;
	
	@Override
	public boolean init() {
		return super.setClass(SalaryTicket.class, "Salary Ticket", "工资凭据");
	}

	@Override
	public void buildFields() {
		super.buildFields();
		addModelField(EMPLOYEE, "Employee", "职员");
		addModelField(LEAVEAPPHOURS, "leaveapp Hours", "请假小时");
		addModelField(DELIVERYTIMES, "Delivery Items", "外卖单数");
		addModelField(FAULTAMOUNT, "Reware fault amount", "奖惩");
		addModelField(OTHOURS, "ot", "加班小时");
		addModelField(ABSENTDAYS, "Absent days", "旷工天数");
		
		addModelField(LATEMINUTES, "Late minutes", "迟到分钟");
		addModelField(LATETIMES, "Late times", "迟到次数");
		
		addModelField(SCHEDUALDAYS, "Schedua Days", "排班天数");
		addModelField(DUTYDAYS, "Duty Day", "上班天数");
		
		addModelField(SCHEDUALHOURS, "Schedua Hours", "排班时间");
		addModelField(DUTYHOURS, "Duty Hours", "上班时间");
		
		addModelField(DUTYFORGETTIMES, "Forget times", "忘打卡");
		addModelField(DUTYSUBSTITUTETIMES, "Sub times", "代打卡");
		
		addModelField(DAYSALARY, "Mobile", "日薪");
		addModelField(HOURSALARY, "Mobile", "时薪");
		
//		addModelField(ACCTTERM, "Acct Term", "会计期间");
//		addModelField(DEPARTMENT, "Department", "部门");
	}
	
	@Override
	public void prepareLayoutElements() {
//		reCalcTicket = createFunctionButton("_reCalcTicket", "Recalc Ticket", "重算凭据",this.clazz,"_reCalcTicket",false,null,null);
		super.prepareLayoutElements();
	}
	
	@Override
	protected void setDefaultLayoutButtons() {
//		addButton(FunctionButton.EXPORT);
	}
	
	@Override
	protected void addExtraListLayoutButtons() {
//		addButton(reCalcTicket);
	}
	
	@Override
	protected void addSearchFields() {
		super.addSearchField(convertPropertyToField(EMPLOYEE));
	}
	
	@Override
	protected void addListFields() {
		addListField(convertPropertyToField(EMPLOYEE, SCHEDUALDAYS, DUTYDAYS, SCHEDUALHOURS, DUTYHOURS, DAYSALARY, HOURSALARY, LEAVEAPPHOURS,  DELIVERYTIMES, ABSENTDAYS, OTHOURS, FAULTAMOUNT, LATEMINUTES, LATETIMES, DUTYFORGETTIMES, DUTYSUBSTITUTETIMES));
	}
	
	@Override
	protected void addDetailFields() {
		addDetailField(convertPropertyToField(EMPLOYEE, SCHEDUALDAYS, DUTYDAYS, SCHEDUALHOURS, DUTYHOURS, DAYSALARY, HOURSALARY, LEAVEAPPHOURS,  DELIVERYTIMES, ABSENTDAYS, OTHOURS, FAULTAMOUNT, LATEMINUTES, LATETIMES, DUTYFORGETTIMES, DUTYSUBSTITUTETIMES));
	}
	
	
	protected RelatedModel[] getRelatedModels(){
		RelatedModel getLayout = new RelatedModel(this.clazz, "getLayout");
		return new RelatedModel[]{getLayout};
	}
	
	protected TabbedModel[] getTabbedModels(){
		TabbedModel lateItems = new TabbedModel(SalaryTicketLateItem.class, SEARCHRELATEDRESULT);
		TabbedModel leaveEarlyItems = new TabbedModel(SalaryTicketLeaveEarlyItem.class, SEARCHRELATEDRESULT);
		TabbedModel leaveAppItems = new TabbedModel(LeaveAppItem.class, SEARCHRELATEDRESULT);
		return new TabbedModel[]{leaveAppItems, lateItems, leaveEarlyItems};
	}
	
	
//	@Override
//	protected void afterBuilderLayout() {
//		DetailLayout recal = createDetailLayout(model, reCalcTicket.getName(), false, convertPropertyToField(ACCTTERM, DEPARTMENT, EMPLOYEE));
//		bindButtonToLayout(reCalcTicket, recal);
//		super.afterBuilderLayout();
//	}
	
}
